package com.vn.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="Compartment")
public class Compartment {
	
	public Compartment(){}
	
	public Compartment(String id, Building building,
			CompartmentType compartmentType, int floorNumber, double area,
			short occupancyPermit, Date dateReceiveOccupancyPermit, double cost,
			Storage storage, boolean isSold, boolean deleted) {
		super();
		this.id = id;
		this.building = building;
		this.compartmentType = compartmentType;
		this.floorNumber = floorNumber;
		this.area = area;
		this.occupancyPermit = occupancyPermit;
		this.dateReceiveOccupancyPermit = dateReceiveOccupancyPermit;
		this.cost = cost;
		this.storage = storage;
		this.isSold = isSold;
		this.deleted = deleted;
	}

	@Id
	@Column(name="IDCompartment")
	private String id;
	
	@JoinColumn(name="BuildingID",referencedColumnName="IDBuilding")
	@ManyToOne
	private Building building;
	
	@JoinColumn(name="CompartmentTypeID",referencedColumnName="IDCompartmentType")
	@ManyToOne
	private CompartmentType compartmentType;
	
	@Column(name="FloorNumber")
	private int floorNumber;
	
	@Column(name="Area")
	private double area;
	
	@Column(name="OccupancyPermit")
	private short occupancyPermit=0;
	
	@Column(name="DateReceiveOccupancyPermit")
	private Date dateReceiveOccupancyPermit;
	
	@Column(name="Cost")
	private double cost;
	
	@JoinColumn(name="FolderName",referencedColumnName="FolderName")
	@ManyToOne
	private Storage storage;
	
	@Column(name="IsSold")
	private boolean isSold=false;
	
	@Column(name="Deleted")
	private boolean deleted=false;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Building getBuilding() {
		return building;
	}

	public void setBuilding(Building building) {
		this.building = building;
	}

	public CompartmentType getCompartmentType() {
		return compartmentType;
	}

	public void setCompartmentType(CompartmentType compartmentType) {
		this.compartmentType = compartmentType;
	}

	public int getFloorNumber() {
		return floorNumber;
	}

	public void setFloorNumber(int floorNumber) {
		this.floorNumber = floorNumber;
	}

	public double getArea() {
		return area;
	}

	public void setArea(double area) {
		this.area = area;
	}

	public short getOccupancyPermit() {
		return occupancyPermit;
	}

	public void setOccupancyPermit(short occupancyPermit) {
		this.occupancyPermit = occupancyPermit;
	}

	public Date getDateReceiveOccupancyPermit() {
		return dateReceiveOccupancyPermit;
	}

	public void setDateReceiveOccupancyPermit(Date dateReceiveOccupancyPermit) {
		this.dateReceiveOccupancyPermit = dateReceiveOccupancyPermit;
	}

	public double getCost() {
		return cost;
	}

	public void setCost(double cost) {
		this.cost = cost;
	}

	public Storage getStorage() {
		return storage;
	}

	public void setStorage(Storage storage) {
		this.storage = storage;
	}

	public boolean isSold() {
		return isSold;
	}

	public void setSold(boolean isSold) {
		this.isSold = isSold;
	}

	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}
	
	@OneToMany
	private List<PurchaseContract> purchaseContracts;

	public List<PurchaseContract> getPurchaseContracts() {
		return purchaseContracts;
	}

	public void setPurchaseContracts(List<PurchaseContract> purchaseContracts) {
		this.purchaseContracts = purchaseContracts;
	}
	
	
}
